home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / ipworks / email.fr_ / email.fr (.txt)
Encoding:
Visual Basic Form  |  1996-03-14  |  7.7 KB  |  257 lines

  1. VERSION 2.00
  2. Begin Form frmMain 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "EMAIL DEMO"
  5.    ClientHeight    =   4770
  6.    ClientLeft      =   915
  7.    ClientTop       =   1440
  8.    ClientWidth     =   7065
  9.    Height          =   5175
  10.    Left            =   855
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   4770
  13.    ScaleWidth      =   7065
  14.    Top             =   1095
  15.    Width           =   7185
  16.    Begin CommandButton Command5 
  17.       Caption         =   "Compose"
  18.       Height          =   315
  19.       Left            =   4920
  20.       TabIndex        =   13
  21.       Top             =   840
  22.       Width           =   1095
  23.    End
  24.    Begin CommandButton Command4 
  25.       Caption         =   "Retrieve Message"
  26.       Height          =   315
  27.       Left            =   1800
  28.       TabIndex        =   11
  29.       Top             =   840
  30.       Width           =   1815
  31.    End
  32.    Begin CommandButton Command3 
  33.       Caption         =   "Disconnect"
  34.       Height          =   315
  35.       Left            =   3660
  36.       TabIndex        =   3
  37.       Top             =   840
  38.       Width           =   1215
  39.    End
  40.    Begin TextBox tPassword 
  41.       Height          =   285
  42.       Left            =   3720
  43.       PasswordChar    =   "*"
  44.       TabIndex        =   7
  45.       Top             =   480
  46.       Width           =   1515
  47.    End
  48.    Begin TextBox tUser 
  49.       Height          =   285
  50.       Left            =   1200
  51.       TabIndex        =   6
  52.       Top             =   480
  53.       Width           =   1335
  54.    End
  55.    Begin TextBox tMailServer 
  56.       Height          =   285
  57.       Left            =   1200
  58.       TabIndex        =   5
  59.       Top             =   120
  60.       Width           =   2535
  61.    End
  62.    Begin CommandButton Command2 
  63.       Caption         =   "Reply"
  64.       Height          =   315
  65.       Left            =   6060
  66.       TabIndex        =   4
  67.       Top             =   840
  68.       Width           =   915
  69.    End
  70.    Begin CommandButton Command1 
  71.       Caption         =   "Check Messages"
  72.       Height          =   315
  73.       Left            =   60
  74.       TabIndex        =   2
  75.       Top             =   840
  76.       Width           =   1695
  77.    End
  78.    Begin TextBox tMessage 
  79.       FontBold        =   0   'False
  80.       FontItalic      =   0   'False
  81.       FontName        =   "MS Sans Serif"
  82.       FontSize        =   8.25
  83.       FontStrikethru  =   0   'False
  84.       FontUnderline   =   0   'False
  85.       Height          =   1815
  86.       Left            =   0
  87.       MultiLine       =   -1  'True
  88.       ScrollBars      =   2  'Vertical
  89.       TabIndex        =   1
  90.       Top             =   2880
  91.       Width           =   6975
  92.    End
  93.    Begin ListBox lMessages 
  94.       FontBold        =   0   'False
  95.       FontItalic      =   0   'False
  96.       FontName        =   "MS Sans Serif"
  97.       FontSize        =   8.25
  98.       FontStrikethru  =   0   'False
  99.       FontUnderline   =   0   'False
  100.       Height          =   1395
  101.       Left            =   0
  102.       TabIndex        =   0
  103.       Top             =   1200
  104.       Width           =   6975
  105.    End
  106.    Begin POP POP1 
  107.       Height          =   420
  108.       Left            =   5280
  109.       MailServer      =   ""
  110.       Password        =   ""
  111.       RegHandle       =   EMAIL.FRX:0000
  112.       Top             =   0
  113.       User            =   ""
  114.       Width           =   420
  115.       WinsockLoaded   =   0   'False
  116.    End
  117.    Begin Label lStats 
  118.       BackStyle       =   0  'Transparent
  119.       Height          =   255
  120.       Left            =   120
  121.       TabIndex        =   12
  122.       Top             =   2640
  123.       Width           =   5895
  124.    End
  125.    Begin Label Label1 
  126.       BackStyle       =   0  'Transparent
  127.       Caption         =   "Password:"
  128.       Height          =   255
  129.       Index           =   2
  130.       Left            =   2760
  131.       TabIndex        =   10
  132.       Top             =   540
  133.       Width           =   975
  134.    End
  135.    Begin Label Label1 
  136.       BackStyle       =   0  'Transparent
  137.       Caption         =   "User:"
  138.       Height          =   255
  139.       Index           =   1
  140.       Left            =   120
  141.       TabIndex        =   9
  142.       Top             =   540
  143.       Width           =   855
  144.    End
  145.    Begin Label Label1 
  146.       BackStyle       =   0  'Transparent
  147.       Caption         =   "Mail Server:"
  148.       Height          =   255
  149.       Index           =   0
  150.       Left            =   120
  151.       TabIndex        =   8
  152.       Top             =   120
  153.       Width           =   1095
  154.    End
  155. Sub Command1_Click ()
  156. POP1.WinsockLoaded = True
  157. lMessages.Clear
  158. If tMailServer = "" Then
  159.     MsgBox "Please supply a valid mail server."
  160.     Exit Sub
  161. End If
  162. POP1.User = tUser
  163. POP1.Password = tPassword
  164. POP1.MailServer = tMailServer
  165. POP1.Action = 1   'Connect
  166. lStats = POP1.MessageCount & " messages " & POP1.TotalSize & " bytes total"
  167. 'now get the first 15 lines from each message
  168. '(looking for Subject and some other headers)
  169. tMessage.Enabled = False
  170. For gCurrMsg = 1 To POP1.MessageCount
  171.     POP1.MessageNumber = gCurrMsg
  172.     gMessages(gCurrMsg).Size = POP1.MessageSize
  173.     'reset message data
  174.     gMessages(gCurrMsg).From = ""
  175.     gMessages(gCurrMsg).Subject = "'"
  176.     gMessages(gCurrMsg).Date = "'"
  177.     gMessages(gCurrMsg).AllHeaders = ""
  178.     'retrieve the first 15 lines
  179.     POP1.MaxLines = 15
  180.     POP1.Action = 3 'Retrieve Message
  181.     'display some message data
  182.     lMessages.AddItem gCurrMsg & Chr$(9) & gMessages(gCurrMsg).Subject & Chr$(9) & gMessages(gCurrMsg).From & Chr$(9) & " (" & gMessages(gCurrMsg).Size & " bytes)"
  183. Next gCurrMsg
  184. End Sub
  185. Sub Command2_Click ()
  186. frmSend.tSubject = "Re: " & gMessages(gCurrMsg).Subject
  187. frmSend.tTo = gMessages(gCurrMsg).From
  188. frmSend.tFrom = ""
  189. frmSend.tMessage = ""
  190. frmSend.Show
  191. End Sub
  192. Sub Command3_Click ()
  193. lMessages.Clear
  194. tMessage = ""
  195. POP1.Action = 2 'Disconnect
  196. End Sub
  197. Sub Command4_Click ()
  198. If lMessages.ListIndex < 0 Then
  199.     MsgBox "Please select a message from the list first."
  200.     Exit Sub
  201. End If
  202. lMessages_DblClick
  203. End Sub
  204. Sub Command5_Click ()
  205. frmSend.tSubject = ""
  206. frmSend.tTo = ""
  207. frmSend.tFrom = ""
  208. frmSend.tMessage = ""
  209. frmSend.Show
  210. End Sub
  211. Sub Form_Resize ()
  212. If WindowState <> 1 Then
  213.     lMessages.Width = ScaleWidth
  214.     tMessage.Width = ScaleWidth
  215.     If ScaleHeight - tMessage.Top > 100 Then
  216.         tMessage.Height = ScaleHeight - tMessage.Top
  217.     End If
  218. End If
  219. End Sub
  220. Sub lMessages_Click ()
  221. lMessages_DblClick
  222. End Sub
  223. Sub lMessages_DblClick ()
  224. gCurrMsg = lMessages.ListIndex + 1
  225. POP1.MessageNumber = gCurrMsg
  226. gMessages(gCurrMsg).Size = POP1.MessageSize
  227. 'reset message data
  228. gMessages(gCurrMsg).From = ""
  229. gMessages(gCurrMsg).Subject = "'"
  230. gMessages(gCurrMsg).Date = "'"
  231. gMessages(gCurrMsg).AllHeaders = ""
  232. gMessages(gCurrMsg).Text = ""
  233. tMessage.Enabled = True 'allow retrieval of text
  234. tMessage = ""
  235. POP1.MaxLines = 0 'all lines
  236. MousePointer = 11
  237. POP1.Action = 3 'Retrieve Message
  238. MousePointer = 0
  239. nl$ = Chr$(13) & Chr$(10)
  240. tMessage = gMessages(gCurrMsg).Text & nl$ & nl$ & String$(30, "-") & nl$ & gMessages(gCurrMsg).AllHeaders
  241. tMessage.SelStart = 0
  242. End Sub
  243. Sub POP1_Header (Field As String, Value As String)
  244. gMessages(gCurrMsg).AllHeaders = gMessages(gCurrMsg).AllHeaders & Field & ": " & Value & Chr$(13) & Chr$(10)
  245. Select Case UCase$(Field)
  246.     Case "SUBJECT": gMessages(gCurrMsg).Subject = Value
  247.     Case "FROM": gMessages(gCurrMsg).From = Value
  248.     Case "DATE": gMessages(gCurrMsg).Date = Value
  249. End Select
  250. End Sub
  251. Sub POP1_PITrail (Direction As Integer, Message As String)
  252. Debug.Print "POP:" & Direction & ": " & Message
  253. End Sub
  254. Sub POP1_Transfer (BytesTransferred As Long, Text As String)
  255. gMessages(gCurrMsg).Text = gMessages(gCurrMsg).Text & Text & Chr$(13) & Chr$(10)
  256. End Sub
  257.